package com.kuangstudy.collection.map;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;

/**
 * ClassName: Demo2
 * date: 2021/07/13 18:40:58
 *
 * @author zlk
 */
public class Demo2 {
    public static void main(String[] args) {
        /*创建集合*/
        HashMap<Student, String> hashMap = new HashMap<>();
        Student s1 = new Student("kk",12);
        Student s2 = new Student("kk1",121);
        Student s3 = new Student("kk2",122);
        Student s4 = new Student("kk3",123);
        hashMap.put(s1,"kk");
        hashMap.put(s2,"kk1");
        hashMap.put(s3,"kk2");
        hashMap.put(s4,"kk3");
        hashMap.put(new Student("kk3",123),"kk3");
        System.out.println(hashMap.toString());
        System.out.println(hashMap.size());
        /*删除*/
        hashMap.remove(s4);
        System.out.println(hashMap.size());
        /*遍历 keySet*/
        for (Student student : hashMap.keySet()) {
            System.out.println(student+"=>"+hashMap.get(student));
        }
        /*遍历 entrySet*/
        for (Map.Entry<Student, String> entry : hashMap.entrySet()) {
            System.out.println(entry.getKey()+"=>"+entry.getValue());
        }
        System.out.println(hashMap.containsKey(s1));

    }
}
